/*
 * MainGUI.java
 *
 * Created on Oct 30, 2011, 12:07:42 PM
 */

package gui;
/**
 *
 * @author suzann
 */

/*
 * Import Java Classes
 */

import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyVetoException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

import java.util.Collections;
import java.util.List;
import java.util.Vector;

import db.DatabaseManager;
import db.entity.StationConnection;
import taper.controller.TaperController;
import util.*;


public class MainGUI extends JFrame {

    /** Creates new form MainGUI */
    public MainGUI() 
    {
        // Start backend processes
    	new TaperController().startBackEnd();
//    	try {
//			PropertiesLoader.getInstance();
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
        initComponents();
        initFrames();
        _instance = this;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jpnConnStat = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jpnlConnStat1 = new javax.swing.JPanel();
        jlblConnStat1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jpnlConnStat2 = new javax.swing.JPanel();
        jlblConnStat2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jpnlConnStat3 = new javax.swing.JPanel();
        jlblConnStat3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jpnlConnStat4 = new javax.swing.JPanel();
        jlblConnStat4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jpnlConnStat5 = new javax.swing.JPanel();
        jlblConnStat5 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jpnlConnStat6 = new javax.swing.JPanel();
        jlblConnStat6 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jpnlConnStat7 = new javax.swing.JPanel();
        jlblConnStat7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jpnlConnStat8 = new javax.swing.JPanel();
        jlblConnStat8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jpnlConnStat9 = new javax.swing.JPanel();
        jlblConnStat9 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jpnlConnStat10 = new javax.swing.JPanel();
        jlblConnStat10 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jbtManagePadBatchID = new javax.swing.JButton();
        jbtNewSPC = new javax.swing.JButton();
        jbtQuerySPC = new javax.swing.JButton();
        jbtVacVal = new javax.swing.JButton();
        jbtPreVal = new javax.swing.JButton();
        jbtQueryData = new javax.swing.JButton();
        jbtMonLiveData = new javax.swing.JButton();
        jbtCoefCorr = new javax.swing.JButton();
        jbtActivateStation = new javax.swing.JButton();
        jbtPareto = new javax.swing.JButton();
        jbtPolyVal = new javax.swing.JButton();
        jbtTendChart = new javax.swing.JButton();
        jbtTapperIDMapping = new javax.swing.JButton();
        jbtViewLog = new javax.swing.JButton();
        jbtManageUsers = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jmiExit = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(1050, 482));

        jLabel1.setText("01");

        jpnlConnStat1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jpnlConnStat1.setMaximumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat1.setMinimumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat1.setPreferredSize(new java.awt.Dimension(360, 25));

        jlblConnStat1.setText("Connecting...");

        javax.swing.GroupLayout jpnlConnStat1Layout = new javax.swing.GroupLayout(jpnlConnStat1);
        jpnlConnStat1.setLayout(jpnlConnStat1Layout);
        jpnlConnStat1Layout.setHorizontalGroup(
            jpnlConnStat1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlConnStat1Layout.createSequentialGroup()
                .addComponent(jlblConnStat1)
                .addContainerGap(290, Short.MAX_VALUE))
        );
        jpnlConnStat1Layout.setVerticalGroup(
            jpnlConnStat1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jlblConnStat1)
        );

        jLabel2.setText("02");

        jpnlConnStat2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jpnlConnStat2.setMaximumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat2.setMinimumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat2.setPreferredSize(new java.awt.Dimension(360, 25));

        jlblConnStat2.setText("Connecting...");

        javax.swing.GroupLayout jpnlConnStat2Layout = new javax.swing.GroupLayout(jpnlConnStat2);
        jpnlConnStat2.setLayout(jpnlConnStat2Layout);
        jpnlConnStat2Layout.setHorizontalGroup(
            jpnlConnStat2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlConnStat2Layout.createSequentialGroup()
                .addComponent(jlblConnStat2)
                .addContainerGap(290, Short.MAX_VALUE))
        );
        jpnlConnStat2Layout.setVerticalGroup(
            jpnlConnStat2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jlblConnStat2)
        );

        jLabel3.setText("03");

        jpnlConnStat3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jpnlConnStat3.setMaximumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat3.setMinimumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat3.setPreferredSize(new java.awt.Dimension(360, 25));

        jlblConnStat3.setText("Connecting...");

        javax.swing.GroupLayout jpnlConnStat3Layout = new javax.swing.GroupLayout(jpnlConnStat3);
        jpnlConnStat3.setLayout(jpnlConnStat3Layout);
        jpnlConnStat3Layout.setHorizontalGroup(
            jpnlConnStat3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlConnStat3Layout.createSequentialGroup()
                .addComponent(jlblConnStat3)
                .addContainerGap(290, Short.MAX_VALUE))
        );
        jpnlConnStat3Layout.setVerticalGroup(
            jpnlConnStat3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jlblConnStat3)
        );

        jLabel5.setText("04");

        jpnlConnStat4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jpnlConnStat4.setMaximumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat4.setMinimumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat4.setPreferredSize(new java.awt.Dimension(360, 25));

        jlblConnStat4.setText("Connecting...");

        javax.swing.GroupLayout jpnlConnStat4Layout = new javax.swing.GroupLayout(jpnlConnStat4);
        jpnlConnStat4.setLayout(jpnlConnStat4Layout);
        jpnlConnStat4Layout.setHorizontalGroup(
            jpnlConnStat4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlConnStat4Layout.createSequentialGroup()
                .addComponent(jlblConnStat4)
                .addContainerGap(290, Short.MAX_VALUE))
        );
        jpnlConnStat4Layout.setVerticalGroup(
            jpnlConnStat4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jlblConnStat4)
        );

        jLabel6.setText("05");

        jpnlConnStat5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jpnlConnStat5.setMaximumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat5.setMinimumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat5.setPreferredSize(new java.awt.Dimension(360, 25));

        jlblConnStat5.setText("Connecting...");

        javax.swing.GroupLayout jpnlConnStat5Layout = new javax.swing.GroupLayout(jpnlConnStat5);
        jpnlConnStat5.setLayout(jpnlConnStat5Layout);
        jpnlConnStat5Layout.setHorizontalGroup(
            jpnlConnStat5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlConnStat5Layout.createSequentialGroup()
                .addComponent(jlblConnStat5)
                .addContainerGap(290, Short.MAX_VALUE))
        );
        jpnlConnStat5Layout.setVerticalGroup(
            jpnlConnStat5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jlblConnStat5)
        );

        jLabel7.setText("06");

        jpnlConnStat6.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jpnlConnStat6.setMaximumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat6.setMinimumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat6.setPreferredSize(new java.awt.Dimension(360, 25));

        jlblConnStat6.setText("Connecting...");

        javax.swing.GroupLayout jpnlConnStat6Layout = new javax.swing.GroupLayout(jpnlConnStat6);
        jpnlConnStat6.setLayout(jpnlConnStat6Layout);
        jpnlConnStat6Layout.setHorizontalGroup(
            jpnlConnStat6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlConnStat6Layout.createSequentialGroup()
                .addComponent(jlblConnStat6)
                .addContainerGap(290, Short.MAX_VALUE))
        );
        jpnlConnStat6Layout.setVerticalGroup(
            jpnlConnStat6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jlblConnStat6)
        );

        jLabel8.setText("07");

        jpnlConnStat7.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jpnlConnStat7.setMaximumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat7.setMinimumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat7.setPreferredSize(new java.awt.Dimension(360, 25));

        jlblConnStat7.setText("Connecting...");

        javax.swing.GroupLayout jpnlConnStat7Layout = new javax.swing.GroupLayout(jpnlConnStat7);
        jpnlConnStat7.setLayout(jpnlConnStat7Layout);
        jpnlConnStat7Layout.setHorizontalGroup(
            jpnlConnStat7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlConnStat7Layout.createSequentialGroup()
                .addComponent(jlblConnStat7)
                .addContainerGap(290, Short.MAX_VALUE))
        );
        jpnlConnStat7Layout.setVerticalGroup(
            jpnlConnStat7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlConnStat7Layout.createSequentialGroup()
                .addComponent(jlblConnStat7)
                .addContainerGap(2, Short.MAX_VALUE))
        );

        jLabel9.setText("08");

        jpnlConnStat8.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jpnlConnStat8.setMaximumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat8.setMinimumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat8.setPreferredSize(new java.awt.Dimension(360, 25));

        jlblConnStat8.setText("Connecting...");

        javax.swing.GroupLayout jpnlConnStat8Layout = new javax.swing.GroupLayout(jpnlConnStat8);
        jpnlConnStat8.setLayout(jpnlConnStat8Layout);
        jpnlConnStat8Layout.setHorizontalGroup(
            jpnlConnStat8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlConnStat8Layout.createSequentialGroup()
                .addComponent(jlblConnStat8)
                .addContainerGap(290, Short.MAX_VALUE))
        );
        jpnlConnStat8Layout.setVerticalGroup(
            jpnlConnStat8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jlblConnStat8)
        );

        jLabel10.setText("09");

        jpnlConnStat9.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jpnlConnStat9.setMaximumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat9.setMinimumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat9.setPreferredSize(new java.awt.Dimension(360, 25));

        jlblConnStat9.setText("Connecting...");

        javax.swing.GroupLayout jpnlConnStat9Layout = new javax.swing.GroupLayout(jpnlConnStat9);
        jpnlConnStat9.setLayout(jpnlConnStat9Layout);
        jpnlConnStat9Layout.setHorizontalGroup(
            jpnlConnStat9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlConnStat9Layout.createSequentialGroup()
                .addComponent(jlblConnStat9)
                .addContainerGap(290, Short.MAX_VALUE))
        );
        jpnlConnStat9Layout.setVerticalGroup(
            jpnlConnStat9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jlblConnStat9)
        );

        jLabel11.setText("10");

        jpnlConnStat10.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jpnlConnStat10.setMaximumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat10.setMinimumSize(new java.awt.Dimension(360, 25));
        jpnlConnStat10.setPreferredSize(new java.awt.Dimension(360, 25));

        jlblConnStat10.setText("Connecting...");

        javax.swing.GroupLayout jpnlConnStat10Layout = new javax.swing.GroupLayout(jpnlConnStat10);
        jpnlConnStat10.setLayout(jpnlConnStat10Layout);
        jpnlConnStat10Layout.setHorizontalGroup(
            jpnlConnStat10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlConnStat10Layout.createSequentialGroup()
                .addComponent(jlblConnStat10)
                .addContainerGap(290, Short.MAX_VALUE))
        );
        jpnlConnStat10Layout.setVerticalGroup(
            jpnlConnStat10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jlblConnStat10)
        );

        javax.swing.GroupLayout jpnConnStatLayout = new javax.swing.GroupLayout(jpnConnStat);
        jpnConnStat.setLayout(jpnConnStatLayout);
        jpnConnStatLayout.setHorizontalGroup(
            jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnConnStatLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpnConnStatLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jpnlConnStat2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnConnStatLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jpnlConnStat3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnConnStatLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jpnlConnStat1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnConnStatLayout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jpnlConnStat8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnConnStatLayout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jpnlConnStat9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnConnStatLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jpnlConnStat10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnConnStatLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jpnlConnStat7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnConnStatLayout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jpnlConnStat4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnConnStatLayout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jpnlConnStat5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnConnStatLayout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jpnlConnStat6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(584, Short.MAX_VALUE))
        );
        jpnConnStatLayout.setVerticalGroup(
            jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnConnStatLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jpnlConnStat1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpnlConnStat2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpnlConnStat3, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpnlConnStat4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpnlConnStat5, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpnlConnStat6, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(jpnlConnStat7, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(5, 5, 5)
                .addGroup(jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpnlConnStat8, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpnlConnStat9, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpnConnStatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpnlConnStat10, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addContainerGap(124, Short.MAX_VALUE))
        );

        getContentPane().add(jpnConnStat, java.awt.BorderLayout.CENTER);

        jbtManagePadBatchID.setText("Manage Pad Batch ID");
        jbtManagePadBatchID.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtManagePadBatchIDActionPerformed(evt);
            }
        });

        jbtNewSPC.setText("New SPC");
        jbtNewSPC.setToolTipText("New SPC");
        jbtNewSPC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtNewSPCActionPerformed(evt);
            }
        });

        jbtQuerySPC.setText("Query SPC");
        jbtQuerySPC.setToolTipText("Query SPC");
        jbtQuerySPC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtQuerySPCActionPerformed(evt);
            }
        });

        jbtVacVal.setText("Vacuum Value");
        jbtVacVal.setToolTipText("Vacuum Value");
        jbtVacVal.setMaximumSize(new java.awt.Dimension(87, 23));
        jbtVacVal.setMinimumSize(new java.awt.Dimension(87, 23));
        jbtVacVal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtVacValActionPerformed(evt);
            }
        });

        jbtPreVal.setText("Pressure Value");
        jbtPreVal.setToolTipText("Pressure Value");
        jbtPreVal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtPreValActionPerformed(evt);
            }
        });

        jbtQueryData.setText("Query Data");
        jbtQueryData.setToolTipText("Query Data");
        jbtQueryData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtQueryDataActionPerformed(evt);
            }
        });

        jbtMonLiveData.setText("Monitor Live Data");
        jbtMonLiveData.setToolTipText("Monitor Live Data");
        jbtMonLiveData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtMonLiveDataActionPerformed(evt);
            }
        });

        jbtCoefCorr.setText("Coefficient Correction");
        jbtCoefCorr.setToolTipText("Coefficient Correction");
        jbtCoefCorr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtCoefCorrActionPerformed(evt);
            }
        });

        jbtActivateStation.setText("Activate Station");
        jbtActivateStation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtActivateStationActionPerformed(evt);
            }
        });

        jbtPareto.setText("Pareto");
        jbtPareto.setToolTipText("Pareto");
        jbtPareto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtParetoActionPerformed(evt);
            }
        });

        jbtPolyVal.setText("Polynomial");
        jbtPolyVal.setToolTipText("Polynomial");
        jbtPolyVal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtPolyValActionPerformed(evt);
            }
        });

        jbtTendChart.setText("Tend Chart");
        jbtTendChart.setToolTipText("Tend Chart");
        jbtTendChart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtTendChartActionPerformed(evt);
            }
        });

        jbtTapperIDMapping.setText("Taper ID Mapper");
        jbtTapperIDMapping.setToolTipText("Taper ID Mapper");
        jbtTapperIDMapping.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtTapperIDMappingActionPerformed(evt);
            }
        });

        jbtViewLog.setText("View Log");
        jbtViewLog.setToolTipText("View Log");
        jbtViewLog.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtViewLogActionPerformed(evt);
            }
        });

        jbtManageUsers.setText("Manage Users");
        jbtManageUsers.setToolTipText("Manage Users");
        jbtManageUsers.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtManageUsersActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jbtQueryData, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jbtMonLiveData))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jbtNewSPC, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jbtQuerySPC))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jbtTendChart, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jbtVacVal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jbtPareto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jbtPreVal))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jbtPolyVal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jbtCoefCorr))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jbtActivateStation, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jbtManagePadBatchID))
                        .addGap(18, 18, 18)
                        .addComponent(jbtTapperIDMapping)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jbtManageUsers)
                            .addComponent(jbtViewLog, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 950, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtMonLiveData)
                    .addComponent(jbtNewSPC)
                    .addComponent(jbtVacVal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtPreVal)
                    .addComponent(jbtPolyVal)
                    .addComponent(jbtActivateStation)
                    .addComponent(jbtViewLog)
                    .addComponent(jbtTapperIDMapping))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtQueryData)
                    .addComponent(jbtQuerySPC)
                    .addComponent(jbtTendChart)
                    .addComponent(jbtPareto)
                    .addComponent(jbtCoefCorr)
                    .addComponent(jbtManagePadBatchID)
                    .addComponent(jbtManageUsers))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        getContentPane().add(jPanel2, java.awt.BorderLayout.PAGE_START);

        jMenu1.setText("File");

        jmiExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        jmiExit.setText("Exit");
        jmiExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiExitActionPerformed(evt);
            }
        });
        jMenu1.add(jmiExit);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-986)/2, (screenSize.height-520)/2, 986, 520);
    }// </editor-fold>

    /** This method is to load all the frames and panels when the application starts.
     */
    private void initFrames()
    {
        frmVacVal = new VacuumValueFrame();createExternalFrame("Vacuum Value Setting",frmVacVal);
        frmPreVal = new PressureValueFrame();createExternalFrame("Pressure Value Setting",frmPreVal);
        frmPoly = new PolynomialInputFrame();createExternalFrame("Polynomial User Input",frmPoly);
        frmCoefCorr = new CoefficientValueSettingFrame();createExternalFrame("Coefficient Value Setting",frmCoefCorr);
        frmMonitorLiveData = new MonitorLiveDataFrame();createExternalFrame("Monitor Live Data",frmMonitorLiveData);
        frmNewSPC = new NewSPCFrame();createExternalFrame("New SPC",frmNewSPC);
        frmQuerySPC = new QuerySPCFrame();createExternalFrame("Query SPC",frmQuerySPC);
        frmTapperIDMapper = new TaperIDMapperFrame();createExternalFrame("Taper ID Mapper",frmTapperIDMapper);
        frmManageUsersFrame = new ManageUsersFrame();createExternalFrame("Manager Users",frmManageUsersFrame);
        frmQueryData = new QueryDataFrame();createExternalFrame("Query Data",frmQueryData);
        frmTendChart = new TendChartFrame();createExternalFrame("Tend Chart",frmTendChart);
        frmActivateStation = new ActivateStationFrame();createExternalFrame("Activate Station", frmActivateStation);
        frmManagePadBatchID = new ManagePadBatchIDFrame();createExternalFrame("Manage Pad Batch ID", frmManagePadBatchID);
        frmActivityLog = new ActivityLogFrame();createExternalFrame("Activity Log", frmActivityLog);
        frmPareto = new ParetoFrame();createExternalFrame("Pareto", frmPareto);
        
        //This is to start the thread that continuously get data from database and update the Connection Status
//        ct = new ConnectionThread();
//        ct.start();
    }
    private void jbtVacValActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // Open the Vacuum Value Setting frame
        showFrame(frmVacVal);        
    }                                         

    private void jbtTendChartActionPerformed(java.awt.event.ActionEvent evt) {                                             
        showFrame(frmTendChart);   
    }                                            

    private void jbtPreValActionPerformed(java.awt.event.ActionEvent evt) {                                          
        showFrame(frmPreVal);
    }                                         

    private void jbtPolyValActionPerformed(java.awt.event.ActionEvent evt) {                                           
        showFrame(frmPoly);
    }                                          

    private void jbtCoefCorrActionPerformed(java.awt.event.ActionEvent evt) {                                            
        showFrame(frmCoefCorr);
    }                                           

    private void jmiExitActionPerformed(java.awt.event.ActionEvent evt) {                                        
        onExit();
    }                                       

    private void jbtMonLiveDataActionPerformed(java.awt.event.ActionEvent evt) {                                               
        frmMonitorLiveData.startMonitor();
        showFrame(frmMonitorLiveData);
    }                                              

    private void jbtNewSPCActionPerformed(java.awt.event.ActionEvent evt) {                                          
        showFrame(frmNewSPC);
    }                                         

    private void jbtQueryDataActionPerformed(java.awt.event.ActionEvent evt) {                                             
        showFrame(frmQueryData);
    }                                            

    private void jbtQuerySPCActionPerformed(java.awt.event.ActionEvent evt) {                                            
        showFrame(frmQuerySPC);
    }                                           

    private void jbtTapperIDMappingActionPerformed(java.awt.event.ActionEvent evt) {                                                   
        showFrame(frmTapperIDMapper);
    }                                                  

    private void jbtManageUsersActionPerformed(java.awt.event.ActionEvent evt) {                                               
        //TODO remove this line when actual implementation is done
        try {
			util.PropertiesLoader.getInstance();
		} catch (Exception e) {
			e.printStackTrace();
		}
    	
    	// Validate Admin ID before showFrame
    	boolean valid = false;
    	String username;
    	do
        {
            username = Authentication.authenticateAdmin();
            if(username.equals("Invalid"))
            {
                JOptionPane.showMessageDialog(this, "Admin ID is invalid.\nPlease enter again.", "Authentication Failure", JOptionPane.WARNING_MESSAGE);
                System.out.println("Authentication failure attempted."); //Can be included into activity log later.
                continue;
            }
            else if (username.equals("Exit"))
            {
                System.out.println("showFrame(frmManageUsersFrame) action terminated."); //Can be included into activity log later.
                break;
            }
            else
            {
                if (username != null)
                {
                    valid = true;
                	showFrame(frmManageUsersFrame);
                }
            }
        }while(valid == false);
    }                                              

    private void jbtActivateStationActionPerformed(java.awt.event.ActionEvent evt) {                                                   
        showFrame(frmActivateStation);
    }                                                  

    private void jbtManagePadBatchIDActionPerformed(java.awt.event.ActionEvent evt) {                                                    
        showFrame(frmManagePadBatchID);
    }                                                   

    private void jbtViewLogActionPerformed(java.awt.event.ActionEvent evt) {                                           
        showFrame(frmActivityLog);
    }                                          

    private void jbtParetoActionPerformed(java.awt.event.ActionEvent evt) {                                          
        showFrame(frmPareto);
    }                                         

    /**
     * Methods
     */
    
    /****************************************************************************
     * METHODS : THE HACKS
     ****************************************************************************/
    
    protected void processWindowEvent(WindowEvent we)
    {
            if(we.getID() == WindowEvent.WINDOW_CLOSING)
                    onExit();
    }
    /****************************************************************************
     * INTERNAL OPERATIONS : THE FRAME
     ****************************************************************************/
    
    /**
     * Prompts up a confirmation dialog to confirm the exit action.
     * Upon confirmation, exit the program, together with all the external frames.
     */
    private void onExit()
    {
            int result = JOptionPane.showConfirmDialog
                                     (	this,
                                            "Are you sure you want to exit this program?",
                                            "Exit Confirmation",
                                            JOptionPane.YES_NO_OPTION,
                                            JOptionPane.QUESTION_MESSAGE
                                     );

            if (result == JOptionPane.YES_OPTION)
            {
                    //storeFrameData();
                    //engine.userLogout();
                    System.exit(0);
            }
    }
    
    /**
     * Used to set external frames properties.
     */
    private void createExternalFrame(String title, JFrame frame)
    {        
        frame.setTitle(title);           
    }
    
    /**
     * Used to set show the frame out.
     */
    private void showFrame(JFrame f)
    {
        f.setVisible(true);
    }
    /**
     * This method is used as to set boolean to opposite value
     */
    private Boolean toggle(Boolean bool)
    {
        return bool = !bool;
    }
    
    //Reading connection from database
    /**
     * @param	connLS	the list of all station connection status in form
     * 					of StationConnection object (db.entity.StationConnection)
     */
    /*private void updateConnection(List<StationConnection> connLS)
    {
    	// The list contains connection status of all station
    	// StationConnection have 2 method: getStationName, getConnect
    	// getStationName retrieve the station number of the object
    	// getConnect get the connection status of the object
                    
        StationConnection sc;
        Vector <String> stationName = new Vector<String>() {};
        Vector <Byte> stationConn = new Vector<Byte>();
        
        //Get the Station Connections      
        for (int i = 0; i < connLS.size(); i++)
        {
            int x = Integer.parseInt(connLS.get(i).getStationName());
            String statusString;
            Color statusColor;
            if (connLS.get(i).isConnect() == true)
            {
                statusString = "Connected";
                statusColor = Color.green;
            }
            else
            {
                statusString = "Disconnected";
                statusColor = Color.red;
            }
            
            if(x == 1)
            {
                jlblConnStat1.setText(statusString);
                jpnlConnStat1.setBackground(statusColor);
            }
            else if(x == 2)
            {
                jlblConnStat2.setText(statusString);
                jpnlConnStat2.setBackground(statusColor);
            }
            else if(x == 3)
            {
                jlblConnStat3.setText(statusString);
                jpnlConnStat3.setBackground(statusColor);
            }
            else if(x == 4)
            {
                jlblConnStat4.setText(statusString);
                jpnlConnStat4.setBackground(statusColor);
            }
            else if(x == 5)
            {
                jlblConnStat5.setText(statusString);
                jpnlConnStat5.setBackground(statusColor);
            }
            else if(x == 6)
            {
                jlblConnStat6.setText(statusString);
                jpnlConnStat6.setBackground(statusColor);
            }
            else if(x == 7)
            {
                jlblConnStat7.setText(statusString);
                jpnlConnStat7.setBackground(statusColor);
            }
            else if(x == 8)
            {
                jlblConnStat8.setText(statusString);
                jpnlConnStat8.setBackground(statusColor);
            }
            else if(x == 9)
            {
                jlblConnStat9.setText(statusString);
                jpnlConnStat9.setBackground(statusColor);
            }
            else if(x == 10)
            {
                jlblConnStat10.setText(statusString);
                jpnlConnStat10.setBackground(statusColor);
            }
        }
    }*/

    //Pending from Brian
    /**
     * Allow user to update the connection status of the PLC station by
     * passing station number and status
     * @param stationNo Number of the station with status change
     * @param stationStatus The new status of the station
     */
    public static void updateConnection(int stationNo, int stationStatus)
    {
    	if (_instance != null)
    		_instance.internalUpdateConnection(stationNo, stationStatus);
    }
    
    private void internalUpdateConnection(int stationNo, int stationStatus)
    {
    	 String statusString="";
         Color statusColor=null;
         
         switch(stationStatus)
         {
         case Constants.STATION_CONNECTED: 
        	 statusString = "Connected";
        	 statusColor = Color.GREEN;
        	 break;
         case Constants.STATION_DISCONNECTED: 
        	 statusString = "Disconnected";
        	 statusColor = Color.RED;
        	 break;
         case Constants.STATION_POLISHING: 
        	 statusString = "Polishing";
        	 statusColor = Color.YELLOW;
        	 break;
         }
                 
         JLabel targetLabel = null;
         JPanel targetPanel = null;
         // get label and panel of station number.
         
         switch(stationNo)
         {
         case 1:
             targetLabel = jlblConnStat1;
             targetPanel = jpnlConnStat1;
             break;
         case 2:
        	 targetLabel = jlblConnStat2;
        	 targetPanel = jpnlConnStat2;
         case 3:
        	 targetLabel = jlblConnStat3;
        	 targetPanel = jpnlConnStat3;
         case 4:
        	 targetLabel = jlblConnStat4;
        	 targetPanel = jpnlConnStat4;
         case 5:
        	 targetLabel = jlblConnStat5;
        	 targetPanel = jpnlConnStat5;
         case 6:
        	 targetLabel = jlblConnStat6;
        	 targetPanel = jpnlConnStat6;
         case 7:
        	 targetLabel = jlblConnStat7;
        	 targetPanel = jpnlConnStat7;
         case 8:
        	 targetLabel = jlblConnStat8;
        	 targetPanel = jpnlConnStat8;
         case 9:
        	 targetLabel = jlblConnStat9;
        	 targetPanel = jpnlConnStat9;
         case 10:
        	 targetLabel = jlblConnStat10;
        	 targetPanel = jpnlConnStat10;
         }
         
         targetLabel.setText(statusString);
         targetPanel.setBackground(statusColor);
    }
    
    /****************************************************************************
     * INTERNAL CLASSES : THE CLASSES
     ****************************************************************************/
    
    /**
     * Thread to retrieve station connection status continously from database.
     *    This thread will retrieve and update the station connection status
     *    every 5 seconds.
     *
    class ConnectionThread extends Thread
    {
    	boolean exit;
    	
    	List<StationConnection> connLS;
    	    	
    	/**
    	 * Thread will initialize variables, and goes into a loop to retrieve
    	 * station connection status and update the display until user exit.
    	 *
    	public void run()
    	{
    		exit = false;
    		dm = new DatabaseManager();   
    		
    		while(!exit)
    		{
    			// get list of StationConnection
    			// update JFrame
    			// thread sleep for 5 seconds before next cycle
    			
    			connLS = dm.listStationConn();
    			updateConnection(connLS);
    			try {
    				ConnectionThread.sleep(5000);
    			} catch (InterruptedException e) {
    				e.printStackTrace();
    			}
    		}// end while
    	}
    	
    	/**
    	 * This method is use to stop the thread.
    	 *
    	public void stopThread()
    	{
    		exit = true;
    	}
    }
    
    /****************************************************************************
     * ENTRY POINT OF THE PROGRAM
     ****************************************************************************/
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() 
            {
                MainGUI main = new MainGUI();
                main.setVisible(true);
                main.setTitle("Polisher Control");
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JButton jbtActivateStation;
    private javax.swing.JButton jbtCoefCorr;
    private javax.swing.JButton jbtManagePadBatchID;
    private javax.swing.JButton jbtManageUsers;
    private javax.swing.JButton jbtMonLiveData;
    private javax.swing.JButton jbtNewSPC;
    private javax.swing.JButton jbtPareto;
    private javax.swing.JButton jbtPolyVal;
    private javax.swing.JButton jbtPreVal;
    private javax.swing.JButton jbtQueryData;
    private javax.swing.JButton jbtQuerySPC;
    private javax.swing.JButton jbtTapperIDMapping;
    private javax.swing.JButton jbtTendChart;
    private javax.swing.JButton jbtVacVal;
    private javax.swing.JButton jbtViewLog;
    private javax.swing.JLabel jlblConnStat1;
    private javax.swing.JLabel jlblConnStat10;
    private javax.swing.JLabel jlblConnStat2;
    private javax.swing.JLabel jlblConnStat3;
    private javax.swing.JLabel jlblConnStat4;
    private javax.swing.JLabel jlblConnStat5;
    private javax.swing.JLabel jlblConnStat6;
    private javax.swing.JLabel jlblConnStat7;
    private javax.swing.JLabel jlblConnStat8;
    private javax.swing.JLabel jlblConnStat9;
    private javax.swing.JMenuItem jmiExit;
    private javax.swing.JPanel jpnConnStat;
    private javax.swing.JPanel jpnlConnStat1;
    private javax.swing.JPanel jpnlConnStat10;
    private javax.swing.JPanel jpnlConnStat2;
    private javax.swing.JPanel jpnlConnStat3;
    private javax.swing.JPanel jpnlConnStat4;
    private javax.swing.JPanel jpnlConnStat5;
    private javax.swing.JPanel jpnlConnStat6;
    private javax.swing.JPanel jpnlConnStat7;
    private javax.swing.JPanel jpnlConnStat8;
    private javax.swing.JPanel jpnlConnStat9;
    // End of variables declaration

    //Variables declaration - not by IDE    
    private VacuumValueFrame frmVacVal;
    private PressureValueFrame frmPreVal;
    private PolynomialInputFrame frmPoly;
    private CoefficientValueSettingFrame frmCoefCorr;
    private MonitorLiveDataFrame frmMonitorLiveData;
    private NewSPCFrame frmNewSPC;
    private QuerySPCFrame frmQuerySPC;
    private TaperIDMapperFrame frmTapperIDMapper;
    private ManageUsersFrame frmManageUsersFrame;
    private QueryDataFrame   frmQueryData;
    private TendChartFrame   frmTendChart;
    private ActivateStationFrame frmActivateStation;
    private ManagePadBatchIDFrame frmManagePadBatchID;
    private ActivityLogFrame frmActivityLog;
    private ParetoFrame frmPareto;
//    private ConnectionThread ct;
    private DatabaseManager dm;
    private static MainGUI _instance = null; 
    
}
